package com.angel.mocks.data.generator.dataGenerator;

import java.io.FileNotFoundException;
import java.io.InputStream;

import com.angel.data.generator.annotations.Generator;
import com.angel.data.generator.annotations.Inject;
import com.angel.data.generator.annotations.importFileProcessorRunner.ImportFileProcessorRunnerBuilder;
import com.angel.data.generator.annotations.inputStream.InputStreamBuilder;
import com.angel.data.generator.exceptions.DataGeneratorException;
import com.angel.io.descriptor.FileProcessorDescriptor;
import com.angel.io.processors.commands.impl.ExcelFileProcessorCommand;
import com.angel.io.processors.runners.imports.impl.ImportFileAnnotationProcessorRunner;
import com.angel.io.processors.runners.imports.impl.ImportFileProcessorRunner;
import com.angel.mocks.daos.AddressDAO;
import com.angel.mocks.io.Hotel;
import com.angel.mocks.io.resourceLocation.ResourceLocation;
import com.angel.mocks.io.rowProcessorCommands.CountryAnnotationRowProcessorCommand;

/**
 *
 * @author William
 */
@Generator
	(
		dependencies = { },
		pages = {1,2},
		daoName = "addressDAO",
		objectClass = Hotel.class
	)
public class ExampleFullAnnotationDataGenerator {

    private static final long serialVersionUID = 456392726459660147L;

    @Inject
    protected AddressDAO addressDAO;

    @ImportFileProcessorRunnerBuilder(fileProcessorDescriptor = FileProcessorDescriptor.class, name = "Rooms File")
    public ImportFileProcessorRunner prepareImportFileProcessorRunner(FileProcessorDescriptor fileProcessorDescriptor) {
    	ImportFileProcessorRunner runner = new ImportFileAnnotationProcessorRunner(fileProcessorDescriptor,new ExcelFileProcessorCommand(), new CountryAnnotationRowProcessorCommand());
        return runner;
    }

    @InputStreamBuilder
    public InputStream prepareInputStream() {
        try {
            return ResourceLocation.findInputStreamFor(ResourceLocation.HOTELES_EXCEL_FILE);
        } catch (FileNotFoundException e) {
            throw new DataGeneratorException("File not found [" + ResourceLocation.HOTELES_EXCEL_FILE + "].", e);
        }
    }
}